/*
 * @Author: fankewen 835656320@qq.com
 * @Date: 2023-12-14 15:15:31
 * @LastEditors: 隔壁小王 18398748175@163.com
 * @LastEditTime: 2024-01-02 14:21:35
 * @FilePath: \symbolimg\demo\src\router\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AEa
 */
import Vue from "vue";
import VueRouter from "vue-router";


Vue.use(VueRouter);

const routes = [{
  path: "/",
  redirect: "/home",
},
{
  path: "/home",
  name: "home",
  component: () =>
    import( /* webpackChunkName: "about" */ "../views/home.vue"),
  children: [{
    path: "/Imgsource",
    name: "Imgsource",
    // redirect:"/Imgsource",
    meta: {
      title: "符号管理"
    },
    component: () =>
      import( /* webpackChunkName: "about" */ "../views/ImgSource/index.vue"),
  },
  {
    path: "/MapEcharts1",
    name: "MapEcharts1",
    // redirect:"/Imgsource",
    meta: {
      title: "符号管理"
    },
    component: () =>
      import( /* webpackChunkName: "about" */ "../views/MapEcharts/Mapecharts1/index.vue"),
  },
  {
    path: "/MapEcharts2",
    name: "MapEcharts2",
    // redirect:"/Imgsource",
    meta: {
      title: "符号管理"
    },
    component: () =>
      import( /* webpackChunkName: "about" */ "../views/MapEcharts/Mapecharts2/index.vue"),
  },
  {
    path: "/Rotate",
    name: "Rotate",
    // redirect:"/Imgsource",
    meta: {
      title: "符号管理"
    },
    component: () =>
      import( /* webpackChunkName: "about" */ "../views/WCSS/Rotate.vue"),
  },
  {
    path: "/animation",
    name: "animation",
    // redirect:"/Imgsource",
    meta: {
      title: "符号管理"
    },
    component: () =>
      import( /* webpackChunkName: "about" */ "../views/WCSS/animation.vue"),
  },
  {
    path: "/menu",
    name: "menu",
    // redirect:"/Imgsource",
    meta: {
      title: "符号管理"
    },
    component: () =>
      import( /* webpackChunkName: "about" */ "../views/WCSS/menu.vue"),
  },
  
  {
    path: "/Drag",
    name: "Drag",
    // redirect:"/Imgsource",
    meta: {
      title: "符号管理"
    },
    component: () =>
      import( /* webpackChunkName: "about" */ "../views/WCSS/Drag.vue"),
  },
  {
    path: "/SweepAway",
    name: "SweepAway",
    // redirect:"/Imgsource",
    meta: {
      title: "符号管理"
    },
    component: () =>
      import( /* webpackChunkName: "about" */ "../views/WCSS/SweepAway.vue"),
  },
  ]
},

{
  path: "/login",
  name: "login",
  component: () =>
    import( /* webpackChunkName: "about" */ "../views/Login.vue"),
},

];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});
const routerPush = VueRouter.prototype.push;
VueRouter.prototype.push = function (location) {
  return routerPush.call(this, location).catch((err) => { })
}
router.beforeEach((to, from, next) => {
  // 判断是否登陆 
  let isLogin = sessionStorage.getItem("ms_username")
  if (!isLogin && to.path != '/login') {
    next("/login")
  } else if (to.meta.title) {
    next()
  } else {
    next()
  }

})

export default router;